<template>
  <div class="login">
    <div id="top">
      <img
        class="img-big"
        src="https://img0.baidu.com/it/u=4076493291,331486562&fm=26&fmt=auto"
        alt=""
      />
      <img class="img-small" src="" alt="" />
    </div>
    <p class="top_p">您还未登录</p>
    <div id="content">
      <div class="ipt">
        <div>
          <i class="el-icon-user"></i>
          <input
            placeholder="请输入用户名"
            v-model="username"
            clearable
            class="input_style"
          />
        </div>
      </div>
      <div class="ipt">
        <div>
          <i class="el-icon-lock"></i>
          <input
            placeholder="请输入密码"
            v-model="pwd"
            show-password
            class="input_style"
          />
        </div>
      </div>
      <div class="btn">
        <button type="primary" @click="login" class="login_style">登录</button>
      </div>
      <div class="btn_zc">
        <span
          >还没有账号?<router-link tag="a" :to="{ name: 'Register' }"
            >去注册</router-link
          ></span
        >
        <span>忘记密码?</span>
      </div>
    </div>
    <div id="bottom">
      <div>第三方登录</div>
      <div class="bottom-icon">
        <i class="iconfont icon-QQ-circle-fill"></i>
        <i class="iconfont icon-weixin-copy"></i>
        <i class="iconfont icon-weibo"></i>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      username: "",
      pwd: "",
      error: {
        name: "",
        pwd: "",
      },
    };
  },
  methods: {
    login() {
      const self = this;
      if (self.username != "" && self.pwd != "") {
        this.ajax({
          method: "post",
          url: "/logindlyz",
          data:{
            name:this.username,
            password:this.pwd
          }
        }).then((res) => {
          // this.school = res.data
          alert(res.data.mes);
          if(res.data.mes=="登录成功"){
            // console.log(res.data.data.indexOf(this.username));
            let dui={
              user:this.username,
            }
            localStorage.user=JSON.stringify(dui)
            this.$router.push("/")
          }
        });
      } else {
        alert("填空不能为空！");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "https://at.alicdn.com/t/font_2877559_d6fsrd66kuw.css?spm=a313x.7781069.1998910419.85&file=font_2877559_d6fsrd66kuw.css";
body {
  margin: 0;
  padding: 0;
}
#bottom {
  margin: auto;
  height: 9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  > div {
    font-size: 12px;
    color: gray;
  }
  > .bottom-icon {
    width: 150px;
    // background-color: green;
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    > i {
      font-size: 26px;
      cursor: pointer;
    }
  }
}
.top_p {
  margin-top: 20px;
  width: 100%;
  text-align: center;
}
.btn_zc {
  width: 100%;
  display: flex;
  margin-top: -20px;
  justify-content: space-around;
  align-items: center;
  font-size: 13px;
  > span:nth-of-type(1) {
    color: gray;
    > a {
      color: #679dce;
    }
  }
  > span:nth-of-type(2) {
    cursor: pointer;
    color: #679dce;
  }
}
#app {
  width: 100%;
  height: 100%;

  .login {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;

    #top {
      width: 100%;
      display: flex;
      justify-content: center;
      flex-direction: column;
      align-items: center;

      .img-big {
        width: 100%;
        border-radius: 0px 0px 50% 50%;
      }

      .img-small {
        width: 6rem;
        height: 6rem;
        margin-top: -55px;
        overflow: hidden;
        border: none;
        border-radius: 50%;
        background-color: gray;
      }
    }

    #content {
      height: 20rem;
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      align-items: center;

      .ipt {
        width: 75%;

        div {
          display: flex;
          align-items: flex-end;
          border-bottom: 1px solid #c2c2c2;

          .el-icon-user {
            font-size: 1.5rem;
            margin-right: 20px;
          }

          .el-icon-lock {
            font-size: 1.5rem;
            margin-right: 20px;
          }
          input {
            width: 100%;
            height: 1.8rem;
            border: none;
            display: flex;
            outline: none;
            color: rgb(100, 100, 100);
            justify-content: center;
          }
        }
      }

      .btn {
        width: 75%;

        button {
          width: 100%;
          height: 2rem;
          margin-top: 2rem;
          background-color: #679dce;
          color: white;
          font-weight: bold;
          font-size: 17px;
          border: none;
          outline: none;
          border-radius: 2px;
        }
      }
    }
  }
}
</style>